import {defineStore} from "pinia"

const useOrderStore = defineStore('orderStore', {
    state() {
        return {
            products: [],
            orderIdList: [],
            all: [],
        }
    },
    actions: {
        saveProducts(products) {
            this.products = products
        },
        saveOrderIdList(orderIdList) {
            this.orderIdList = orderIdList
        },
        saveAll(all) {
            this.all = all
        },
        clear() {
            this.products = []
            this.orderIdList = []
            this.all = []
        }
    },
    getters: {

    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'orderStore',
                storage: window.localStorage,
                paths: ['products', 'orderIdList', 'all']
            }
        ]
    }
})

export default useOrderStore